package com.aa.activity;



import java.util.List;

import com.aa.Common;
import com.aa.NewFavourableActivity;
import com.aa.R;
import com.aa.http.HttpEngine;


import android.support.v4.app.FragmentTransaction;
import android.app.Activity;
import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.preference.Preference;
import android.preference.PreferenceScreen;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class SipCallActivity extends Activity {

	private String mUrl = "http://mimi.mimicall.cn:8888/yaloe/bangdinghaoma.do";
//	private String TAG = "SipCallActivity";
//	private ISipService  service;
//	protected SipProfile account = null;
//	private WizardIface wizard = null;
//	private ISipService mService;
//	private SipService mSipService;
//	  private ServiceConnection connection = new ServiceConnection() {
//
//	        @Override
//	        public void onServiceConnected(ComponentName arg0, IBinder arg1) {
//	        	mService = ISipService.Stub.asInterface(arg1);
//	            	          
//	        	if (mService != null) {
//					Log.i(TAG, "mService is no null");
//				}
//	        }
//
//	        @Override
//	        public void onServiceDisconnected(ComponentName arg0) {
//	        	mService = null;
//	        }
//	    };
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);			

		setContentView(R.layout.sipcall);
		HttpEngine _Engine =new HttpEngine("POST", mUrl, "", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><msisdn>"+Common.iMyPhoneNumber+"</msisdn>" + "<password>" +Common.iPassword + "</password>" + "<smsvalidate>" + Common.smsvalidate + "</smsvalidate>" + "</request>",this);
		_Engine.requestPost();
		
		
//		((Button)findViewById(R.id.sip_call)).setOnClickListener(new OnClickListener() {
//			
//			@Override
//			public void onClick(View v) {
//				try {
//				mService.makeCallWithOptions("8840", 40, null);
//				
//					int i = mService.getVersion();
//					Log.i(TAG, "version = " + i);
//				} catch (RemoteException e) {
//					// TODO Auto-generated catch block
//					e.printStackTrace();
//				}
//				
//			}
//		});
//		
//		new DBAdapter(SipCallActivity.this);
//		
//		Uri uri = getContentResolver().insert(SipProfile.ACCOUNT_URI, getDbContentValues());
//		//getContentResolver().delete(SipProfile.ACCOUNT_URI, null, null);
//		
//		
//		boolean b = bindService(new Intent(SipManager.INTENT_SIP_SERVICE), connection,
//                Context.BIND_AUTO_CREATE);
//		if (b) {
//			Log.i(TAG, "bindService succeful");
//		}else {
//			Log.i(TAG, "bindService fail");
//		}
//		startSipService();
//		Bundle bundle = null;
//		try {
//			//mService.makeCallWithOptions("8840", 1, bundle);
//		
//			//mService.addAllAccounts();
//		} catch (RemoteException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		
//		if (mService.equals( bundle )) {
//			Log.i(TAG, "true");
//		}else {
//			Log.i(TAG, "false");
//		}
//		
		//Intent _Intent = new Intent(SipCallActivity.this, SipService.class);
		
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
	
	@Override
	protected void onResume() {		
		super.onResume();
		
	}

//	public ContentValues getDbContentValues(){
//		SipProfile account = new SipProfile();
//		account.id = 1;
//		account.display_name = "tj";
//		account.transport = 1;
//		account.priority = 100;
//		account.acc_id = "<sip:tj@192.168.89.40>";
//		account.reg_uri = "sip:192.168.89.40";
//		account.proxies = new String[]{"sip:192.168.89.40"};
//		account.realm = "*";
//		account.scheme = "Digest";
//		account.username = "tj";
//		account.data = "fs@tj@8888";
//		
//		return account.getDbContentValues();
//	}
//
//	  private void startSipService() {
//	    	
//	        Thread t = new Thread("StartSip") {
//	            public void run() {
//	                Intent serviceIntent = new Intent(SipManager.INTENT_SIP_SERVICE);
//	                serviceIntent.putExtra(SipManager.EXTRA_OUTGOING_ACTIVITY, new ComponentName(SipCallActivity.this, SipCallActivity.class));
//	                startService(serviceIntent);
//	               // postStartSipService();
//	            };
//	        };
//	        t.start();
//
//	    }
}
